<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>

    // 将多个变量整合到对象中,作为对象的键值

    // ES5 
    var name = "张三";
    var age = 18;
    var height = "173cm";
    var weight = "60kg";

    var zhang = {
        // "name" 键名
        // name  键值(变量)
        name:name,
        age:age,
        height:height,
        weight:weight,

        // 对象中的方法(函数)
        // "say" 键名
        // function 键值(函数/方法)
        say:function(){
            console.log(this.name,this.age);
        }
    }




    // ES6 对象简写
    // 1. 如果对象的键名和键值对应的变量名相同,可以简写成一个
    // 2. 对象的函数可以直接简写  => 省略:function
    var name = "张三";
    var age = 18;
    var height = "173cm";
    var weight = "60kg";
    
    var zhang = {
        name, // name:name
        age,
        height,
        weight,
        say(){
            console.log(this.name,this.age);
        }
    }



</script>
</html>